package xin.marcher.module.inventory.mq.producer;

import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import xin.marcher.module.common.constants.RocketMqConstant;
import xin.marcher.module.inventory.domain.bo.InventoryDetail;

import javax.annotation.Resource;

/**
 * 库存扣减明细
 *
 * 
 */
@Slf4j
@Component
public class InventoryDetailProducer {

    @Resource
    private DefaultProducer defaultProducer;

    /**
     * 库存扣减明细 MQ 生产
     *
     * @param inventoryDetail 库存明细
     */
    public void sendInventoryDetail(InventoryDetail inventoryDetail) {
        //发送库存扣减 明细保存消息
        defaultProducer.sendAsyncMessage(RocketMqConstant.INVENTORY_DETAIL_TOPIC,
                JSONObject.toJSONString(inventoryDetail), "库存扣减明细");
    }
}
